package com.example.jiaju.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.jiaju.R;

import java.util.ArrayList;
import java.util.List;

public class ARModelAdapter extends RecyclerView.Adapter<ARModelAdapter.MyViewHolder>{

    private List<String> list=new ArrayList<>();
    private Context context;

    public ARModelAdapter(List<String> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.ar_model_item,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        String url=list.get(position);
        Glide.with(context).load(url).into(holder.arModelImg);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder{

        private ImageView arModelImg;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            arModelImg=itemView.findViewById(R.id.ar_model_img);
        }
    }
}
